package json.gson;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

import json.jackson.Address;
import json.jackson.All;
import json.jackson.People;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;


public class Test {
	
	public static void main(String[] args) {
		People p1=new People(1, new Address("aa"));
		People p2=new People(2, new Address("bb"));
		List<People> list=new ArrayList<People>();
		list.add(p1);
		list.add(p2);
		
		Gson gson=new Gson();
		String json = gson.toJson(list);  
		System.out.println(json);
		
		Type type=new TypeToken<All>(){}.getType();
		All result=gson.fromJson(json, type);
		System.out.println(result);
	}

}
